package com.wlr.study.pointsword;

/**
 * 青蛙跳台阶
 * 一只青蛙一次可以跳上1级台阶，也可以跳上2级台阶。求该青蛙跳上一个 n 级的台阶总共有多少种跳法。
 *
 * @author lrwang
 * @version 1.0
 * @date 2022/4/2 22:25
 */
public class Offer10_2 {
    public int numWays(int n) {
        if (n <= 1) {
            return 1;
        }
        int a = 1, b = 1, c = 0;
        for (int i = 2; i <= n; i++) {
            c = (a + b) % 1000000007;
            a = b;
            b = c;
        }
        return c;
    }

    public static void main(String[] args) {
        Offer10_2 offer102 = new Offer10_2();

        System.out.println(offer102.numWays(8));
    }
}
